package com.zzj.ecology.admin.controller.minitor;

import com.zzj.ecology.admin.controller.BaseController;
import com.zzj.ecology.common.constant.UrlConstants;
import com.zzj.ecology.common.enums.BusinessType;
import com.zzj.ecology.framework.annotation.Log;
import com.zzj.ecology.framework.annotation.RepeatSubmit;
import com.zzj.ecology.system.domain.Page;
import com.zzj.ecology.system.dto.R;
import com.zzj.ecology.system.service.minitor.SysOperLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "SysOperLog", description = "SysOperLog登录日志操作相关")
@RestController
public class SysOperLogController extends BaseController {

    @Autowired
    private SysOperLogService sysOperLogService;

    /**
     * laytable 分页查询数据
     * @param page
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询用户登录的日志详细信息", httpMethod = "GET")
    @RequestMapping(value = UrlConstants.OperLog.LIST)
    public R findPageList(@ApiParam Page page) {
        return sysOperLogService.findPageList(page);
    }

    @ApiOperation(value = "批量删除", notes = "批量删除操作,注意非标志删除。请注意数据。", httpMethod = "POST")
    @RepeatSubmit
    @Log(title = "用户操作日志", businessType = BusinessType.DELETE)
    @PostMapping(value = UrlConstants.OperLog.DELETE_BY_IDS)
    public R deleteByIds(@RequestParam("ids") @ApiParam List<Integer> operids) {
        if(operids.size() <= 0) return R.ng();
        sysOperLogService.deleteNonreversibleByIds(operids);
        return R.ok();
    }




}
